Skip to content

fix(runtime): route late writes around closed capture buffers - #130

Open
furgalep wants to merge 51 commits into
dev/tuifrom
fix/runtime-closed-capture-buffer
Open

fix(runtime): route late writes around closed capture buffers#130
furgalep wants to merge 51 commits into
dev/tuifrom
fix/runtime-closed-capture-buffer

Conversation

@furgalep

@furgalep furgalep commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • fall back to the original process stream when a task inherits a closed execution-capture buffer
  • cover write, writelines, and flush behavior for stale closed buffers
  • preserve ValueError behavior for buffers that are not actually closed

Why

Background tasks inherit context variables and may outlive the execution capture that installed a StringIO. Late logging or exception reporting then writes to a closed buffer and can mask the original failure. This routes only stale, actually-closed buffers to the process stream.

Verification

  • uv run ruff check src/nooa/runtime/stream_wrappers.py tests/runtime/test_stream_wrappers.py
  • uv run ruff format --check src/nooa/runtime/stream_wrappers.py tests/runtime/test_stream_wrappers.py
  • uv run pytest -q tests/runtime/test_stream_wrappers.py (49 passed)

furgalep and others added 30 commits August 4, 2026 15:25
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
- Persist prompted API keys only after the fetch validates them, so a
  mistyped key no longer overwrites secrets.yaml on failure.
- Drop the api_base override in _llm_endpoint_overrides when api_key_env
  is configured but unresolved, surfacing a missing-key error instead of
  an opaque 401.
- Remove the port-11434 Ollama sniff in registry_entry; OpenAI-compatible
  servers on that port are no longer misrouted to ollama_chat/.
- Guard next() model lookup against StopIteration and cancel gracefully.
- Bound fetch_native_provider_models with a page cap and after_id
  loop detection.
- Invert _DIRECT_ENDPOINT_PROVIDERS to _LOCKED_ENDPOINT_PROVIDERS so
  every LiteLLM provider except cloud-locked ones accepts --api-base.
- Extract _persist_pending_secret and _finalize_alias_and_switch shared
  by _add_to_registry and _add_native_provider.
- Drop the undocumented /model add-to-registry branch (fold into
  /connect); update two tests accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
- Drop the /connect <provider> name macro entirely. /connect only accepts
  a URL; anthropic and ollama shortcuts are gone.
- Detect routing from the URL after normalization:
    - api.anthropic.com hostname -> native anthropic/ flow
    - probe_ollama_backend hits <root>/api/tags with a 3s timeout;
      success routes as ollama_chat/<id> with the root URL as api_base
    - otherwise the existing openai/ flow
- Extend registry_entry with an ollama=True kwarg that emits the
  ollama_chat prefix and strips /v1 from api_base.
- Remove the hardcoded "anthropic" shortcut from the /connect completer.
- Rewrite the README /connect section around URLs.
- Add test_connect_routes_ollama_backend_via_probe and an autouse
  fixture that stubs probe_ollama_backend so unrelated tests do not
  touch the network.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
- Drop --api-base and --api-key-env from the nooa tui CLI and the
  Config.load overrides map.
- Drop TUIConfig.api_base / TUIConfig.api_key_env fields and the
  settings.yaml comment block that documented them.
- Restore get_llm_for_model to its pre-PR single-argument signature; drop
  _llm_endpoint_overrides and _LOCKED_ENDPOINT_PROVIDERS.
- Remove tests covering the removed overrides.
- Clean up stale /connect anthropic mention in health_check fix hints
  and rewrite the README endpoint section to /connect-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
Rewrite around the user-facing flow (start TUI, run /connect, credentials
are stored) and point at .nooa/ for edits via /edit or an external editor.
Drop the wire-protocol detection details from the README.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
Add short comments next to each example URL (Anthropic, OpenAI, Ollama,
vLLM, NVIDIA) so readers see at a glance which backend each entry maps to.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
Signed-off-by: alessiodevoto <adevoto@nvidia.com>
Subviews (model picker, API-key prompt) disable mouse_support so users
can text-select. The Keys.Any handler for active subviews was appending
event.data verbatim to the input buffer, so raw mouse CSI sequences
(clicks, moves) landed in fields like the API-key prompt as garbled
text. Filter parsed mouse KeyPresses and raw mouse CSI byte shapes
before treating input as text. Arrow keys, function keys, and
bracketed paste are unaffected.

Signed-off-by: alessiodevoto <adevoto@nvidia.com>
Drop mouse escape sequences leaking into TUI subview input
furgalep and others added 13 commits August 6, 2026 15:54
Small and mid-size models were treating `explanation` as the reply to the
user (e.g. rendering "∴ done: Responded to user greeting with agent
introduction." instead of an actual greeting) because the field was
described generically as "why handle() returned". Docstring and Field
description now spell out the per-kind rule: DONE/NEED_INPUT must send
user-facing content via self.message() first; WAIT uses explanation as
the intended status surface. Includes right/wrong examples so the pattern
lands in the JSON schema the LLM sees.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…docs

Clarify RespondResult.explanation is not the user reply channel
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
…bility

fix(memory): harden shared SQLite stores
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Normalize spaces for agent attributes and quote space-containing MCP names in slash completion.
@furgalep
furgalep force-pushed the fix/runtime-closed-capture-buffer branch from 77e9370 to 5cb918a Compare August 12, 2026 21:11
alessiodevoto and others added 8 commits August 13, 2026 08:10
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
* fix(mcp): harden OAuth flow in remote TUI sessions

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

* docs(mcp): describe sbx as container runtime

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

* fix: address OAuth review findings

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

---------

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
* fix(skills): honor source-tree entry point targets

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

* fix(skills): preserve entry point target on reload

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

---------

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
* feat(tui): clear input on first Ctrl-C

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

* test(tui): strengthen Ctrl-C input coverage

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

---------

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
* fix(tui): stabilize native scrollback rendering

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

* fix(tui): address render review feedback

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>

---------

Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
Signed-off-by: Paul Furgale <pfurgale@nvidia.com>
@furgalep
furgalep force-pushed the fix/runtime-closed-capture-buffer branch from 5cb918a to f001236 Compare August 19, 2026 06:31
@furgalep
furgalep changed the base branch from main to dev/tui August 19, 2026 06:32
@furgalep furgalep self-assigned this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants